/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: DcmDspSvc14.c
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: Dcm
*
*******************************************************************************/

/** HEADER FILES **/
#include "DcmDspSvc14.h"


/** MACRO DEFINITION **/

/* The following index refer to Dcm_MsgContextType reqData and resData, start after service identifier(which is not part
of this data) */

/* reportNumberOfDTCByStatusMask, reportNumberOfDTCBySeverityMaskRecord, reportNumberOfMirrorMemoryDTCByStatusMask,
reportNumberOfEmissionsRelatedOBDDTCByStatusMask */
#define DCM_REQ_GROUP_OF_DTC_HIGH_INDEX  0u
#define DCM_REQ_GROUP_OF_DTC_MIDDLE_INDEX  1u
#define DCM_REQ_GROUP_OF_DTC_LOW_INDEX  2u

/** TYPEDEF DEFINITION **/


/** LOCAL DATA DECLARATION **/


/** GLOBAL DATA DECLARATION **/


/** LOCAL FUNCTION DECLARATION **/


/** GLOBAL FUNCTION DECLARATION **/
Std_ReturnType DcmDsp_Svc14_Processor(
    Dcm_ExtendedOpStatusType OpStatus,
    Dcm_MsgContextType* pMsgContext,
    Dcm_NegativeResponseCodeType* ErrorCode
);

/** LOCAL DATA **/


/** GLOBAL DATA **/


/** LOCAL FUNCTION **/


/** GLOBAL FUNCTION **/

Std_ReturnType DcmDsp_Svc14_Processor(
    Dcm_ExtendedOpStatusType OpStatus,
    Dcm_MsgContextType* pMsgContext,
    Dcm_NegativeResponseCodeType* ErrorCode
)
{
    Std_ReturnType retVal = E_OK;
    uint32 dtcGroup;

    dtcGroup = ((uint32)(pMsgContext->reqData[DCM_REQ_GROUP_OF_DTC_HIGH_INDEX] << 16u)
          | (uint32)(pMsgContext->reqData[DCM_REQ_GROUP_OF_DTC_MIDDLE_INDEX] << 16u)
          | (uint32)(pMsgContext->reqData[DCM_REQ_GROUP_OF_DTC_LOW_INDEX]));

    Dem_SelectDTC(DemConf_DemClientId_01, dtcGroup, EM_DTC_FORMAT_UDS, DEM_DTC_ORIGIN_PRIMARY_MEMORY);
    Dem_ClearDTC(DemConf_DemClientId_01);
    
    pMsgContext->reqDataLen = 0u;
    
    return(retVal);
}


